package org.queueify;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.google.appengine.api.datastore.Transaction;
import com.google.appengine.api.taskqueue.TaskHandle;

public class QueueifyService {

	static private QueueifyFactory factory = new QueueifyFactory(); 
	
	static public TaskHandle queueTask(Transaction txn, QueueifyTask task) throws QueueifyException {
		return factory.queueTask(txn, task);
	}

	static public List<TaskHandle> queueTask(Transaction txn, java.lang.Iterable<? extends QueueifyTask> tasks) throws QueueifyException {
		return factory.queueTask(txn, tasks);
	}

	static public QueueifyPushQueueTask reconstructPushQueueTask(HttpServletRequest req) throws QueueifyException {
		return factory.reconstructPushQueueTask(req);
	}
	
	static public <T extends QueueifyPullQueueTask> T reconstructPullQueueTask(TaskHandle handle) throws QueueifyException {
		return factory.reconstructPullQueueTask(handle);
	}
	
	static public <T extends QueueifyPullQueueTask> List<T> leaseTasks(Class<? extends QueueifyPullQueueTask> klass, long lease, java.util.concurrent.TimeUnit unit, long countLimit) throws QueueifyException {
		return factory.leaseTasks(klass, lease, unit, countLimit);
	}

	static public <T extends QueueifyPullQueueTask> List<java.lang.Boolean> deleteTask(List<T> taskList) throws QueueifyException {
		return factory.deleteTask(taskList);
	}
	
	static public <T extends QueueifyPullQueueTask> boolean deleteTask(T task) throws QueueifyException {
		return factory.deleteTask(task);
	}

}
